//Monday, October 26 2009
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <math.h>
#include <sstream>
#include <algorithm>

using namespace std;

class Stitch
{
public:
	vector <string> stitch(vector <string> A, vector <string> B, int overlap)
	{
		vector<string> v(A.size(),"");
		for(int i=0; i<A.size(); i++)
		{
			v[i] += A[i].substr(0, A[i].size() - overlap);
			string a = A[i].substr(A[i].size() - overlap);
			string b = B[i].substr(0, overlap);
			v[i] += over(a, b, overlap);
			v[i] += B[i].substr(overlap);
		}
		return v;
	}
	string over(string A, string B, int overlap)
	{
		string ret = "";
		for(int i=0; i<A.size(); i++)
		{
			double temp = ((1.0*overlap-i)*A[i]+(1.0*(1.0+i)*B[i]))/(overlap+1);
			int pix = round(temp);
			ret += char(pix);
		}
		return ret;
	}
};
